// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Cloud Composer API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_orchestration_airflow_service_v1::client::Environments;
/// let client = Environments::builder().build().await?;
/// // use `client` to make requests to the Cloud Composer API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Managed Apache Airflow Environments.
///
/// # Configuration
///
/// To configure `Environments` use the `with_*` methods in the type returned
/// by [builder()][Environments::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://composer.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::environments::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::environments::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Environments` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Environments` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Environments {
    inner: std::sync::Arc<dyn super::stub::dynamic::Environments>,
}

impl Environments {
    /// Returns a builder for [Environments].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_orchestration_airflow_service_v1::client::Environments;
    /// let client = Environments::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::environments::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::environments::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Environments + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Environments>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Environments> {
        super::transport::Environments::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Environments> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Environments::new)
    }

    /// Create a new environment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_environment(&self) -> super::builder::environments::CreateEnvironment {
        super::builder::environments::CreateEnvironment::new(self.inner.clone())
    }

    /// Get an existing environment.
    pub fn get_environment(&self) -> super::builder::environments::GetEnvironment {
        super::builder::environments::GetEnvironment::new(self.inner.clone())
    }

    /// List environments.
    pub fn list_environments(&self) -> super::builder::environments::ListEnvironments {
        super::builder::environments::ListEnvironments::new(self.inner.clone())
    }

    /// Update an environment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_environment(&self) -> super::builder::environments::UpdateEnvironment {
        super::builder::environments::UpdateEnvironment::new(self.inner.clone())
    }

    /// Delete an environment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_environment(&self) -> super::builder::environments::DeleteEnvironment {
        super::builder::environments::DeleteEnvironment::new(self.inner.clone())
    }

    /// Executes Airflow CLI command.
    pub fn execute_airflow_command(&self) -> super::builder::environments::ExecuteAirflowCommand {
        super::builder::environments::ExecuteAirflowCommand::new(self.inner.clone())
    }

    /// Stops Airflow CLI command execution.
    pub fn stop_airflow_command(&self) -> super::builder::environments::StopAirflowCommand {
        super::builder::environments::StopAirflowCommand::new(self.inner.clone())
    }

    /// Polls Airflow CLI command execution and fetches logs.
    pub fn poll_airflow_command(&self) -> super::builder::environments::PollAirflowCommand {
        super::builder::environments::PollAirflowCommand::new(self.inner.clone())
    }

    /// Lists workloads in a Cloud Composer environment. Workload is a unit that
    /// runs a single Composer component.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-2.*.*-airflow-*.*.* and newer.
    pub fn list_workloads(&self) -> super::builder::environments::ListWorkloads {
        super::builder::environments::ListWorkloads::new(self.inner.clone())
    }

    /// Check if an upgrade operation on the environment will succeed.
    ///
    /// In case of problems detailed info can be found in the returned Operation.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn check_upgrade(&self) -> super::builder::environments::CheckUpgrade {
        super::builder::environments::CheckUpgrade::new(self.inner.clone())
    }

    /// Creates a user workloads Secret.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn create_user_workloads_secret(
        &self,
    ) -> super::builder::environments::CreateUserWorkloadsSecret {
        super::builder::environments::CreateUserWorkloadsSecret::new(self.inner.clone())
    }

    /// Gets an existing user workloads Secret.
    /// Values of the "data" field in the response are cleared.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn get_user_workloads_secret(
        &self,
    ) -> super::builder::environments::GetUserWorkloadsSecret {
        super::builder::environments::GetUserWorkloadsSecret::new(self.inner.clone())
    }

    /// Lists user workloads Secrets.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn list_user_workloads_secrets(
        &self,
    ) -> super::builder::environments::ListUserWorkloadsSecrets {
        super::builder::environments::ListUserWorkloadsSecrets::new(self.inner.clone())
    }

    /// Updates a user workloads Secret.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn update_user_workloads_secret(
        &self,
    ) -> super::builder::environments::UpdateUserWorkloadsSecret {
        super::builder::environments::UpdateUserWorkloadsSecret::new(self.inner.clone())
    }

    /// Deletes a user workloads Secret.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn delete_user_workloads_secret(
        &self,
    ) -> super::builder::environments::DeleteUserWorkloadsSecret {
        super::builder::environments::DeleteUserWorkloadsSecret::new(self.inner.clone())
    }

    /// Creates a user workloads ConfigMap.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn create_user_workloads_config_map(
        &self,
    ) -> super::builder::environments::CreateUserWorkloadsConfigMap {
        super::builder::environments::CreateUserWorkloadsConfigMap::new(self.inner.clone())
    }

    /// Gets an existing user workloads ConfigMap.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn get_user_workloads_config_map(
        &self,
    ) -> super::builder::environments::GetUserWorkloadsConfigMap {
        super::builder::environments::GetUserWorkloadsConfigMap::new(self.inner.clone())
    }

    /// Lists user workloads ConfigMaps.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn list_user_workloads_config_maps(
        &self,
    ) -> super::builder::environments::ListUserWorkloadsConfigMaps {
        super::builder::environments::ListUserWorkloadsConfigMaps::new(self.inner.clone())
    }

    /// Updates a user workloads ConfigMap.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn update_user_workloads_config_map(
        &self,
    ) -> super::builder::environments::UpdateUserWorkloadsConfigMap {
        super::builder::environments::UpdateUserWorkloadsConfigMap::new(self.inner.clone())
    }

    /// Deletes a user workloads ConfigMap.
    ///
    /// This method is supported for Cloud Composer environments in versions
    /// composer-3-airflow-*.*.*-build.* and newer.
    pub fn delete_user_workloads_config_map(
        &self,
    ) -> super::builder::environments::DeleteUserWorkloadsConfigMap {
        super::builder::environments::DeleteUserWorkloadsConfigMap::new(self.inner.clone())
    }

    /// Creates a snapshots of a Cloud Composer environment.
    ///
    /// As a result of this operation, snapshot of environment's state is stored
    /// in a location specified in the SaveSnapshotRequest.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn save_snapshot(&self) -> super::builder::environments::SaveSnapshot {
        super::builder::environments::SaveSnapshot::new(self.inner.clone())
    }

    /// Loads a snapshot of a Cloud Composer environment.
    ///
    /// As a result of this operation, a snapshot of environment's specified in
    /// LoadSnapshotRequest is loaded into the environment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn load_snapshot(&self) -> super::builder::environments::LoadSnapshot {
        super::builder::environments::LoadSnapshot::new(self.inner.clone())
    }

    /// Triggers database failover (only for highly resilient environments).
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn database_failover(&self) -> super::builder::environments::DatabaseFailover {
        super::builder::environments::DatabaseFailover::new(self.inner.clone())
    }

    /// Fetches database properties.
    pub fn fetch_database_properties(
        &self,
    ) -> super::builder::environments::FetchDatabaseProperties {
        super::builder::environments::FetchDatabaseProperties::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::environments::ListOperations {
        super::builder::environments::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::environments::GetOperation {
        super::builder::environments::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn delete_operation(&self) -> super::builder::environments::DeleteOperation {
        super::builder::environments::DeleteOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Composer API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_orchestration_airflow_service_v1::client::ImageVersions;
/// let client = ImageVersions::builder().build().await?;
/// // use `client` to make requests to the Cloud Composer API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Readonly service to query available ImageVersions.
///
/// # Configuration
///
/// To configure `ImageVersions` use the `with_*` methods in the type returned
/// by [builder()][ImageVersions::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://composer.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::image_versions::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::image_versions::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ImageVersions` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ImageVersions` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct ImageVersions {
    inner: std::sync::Arc<dyn super::stub::dynamic::ImageVersions>,
}

impl ImageVersions {
    /// Returns a builder for [ImageVersions].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_orchestration_airflow_service_v1::client::ImageVersions;
    /// let client = ImageVersions::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::image_versions::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::image_versions::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ImageVersions + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ImageVersions>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ImageVersions> {
        super::transport::ImageVersions::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ImageVersions> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ImageVersions::new)
    }

    /// List ImageVersions for provided location.
    pub fn list_image_versions(&self) -> super::builder::image_versions::ListImageVersions {
        super::builder::image_versions::ListImageVersions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::image_versions::ListOperations {
        super::builder::image_versions::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::image_versions::GetOperation {
        super::builder::image_versions::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn delete_operation(&self) -> super::builder::image_versions::DeleteOperation {
        super::builder::image_versions::DeleteOperation::new(self.inner.clone())
    }
}
